Single-pulse characterization of the focal spot size of X-ray free-electron lasers using coherent diffraction imaging

A new spot characterization method is proposed, based on coherent diffraction imaging that can accurately determine the focal spot size of a single X-ray free-electron laser pulse. This method was successfully applied to characterize the focal spot size at the Coherent Scattering and Imaging endstation of the Shanghai Soft X-ray Free Electron Laser Facility.


Introduction
The development of X-ray free-electron lasers (XFELs) offers unprecedented opportunities for X-ray science, including high temporal and spatial resolution imaging (Ayyer et al., 2021;Jung et al., 2021) and nonlinear interactions of X-rays with matter (Rohringer & Santra, 2007). XFELs have the advantages of high transverse coherence, high brightness and short pulse duration (Ackermann et al., 2007;Ishikawa et al., 2012;Kang et al., 2017). There are more than 10 10 -10 12 photons in a single pulse. With XFELs, frontier research at the atomic scale and femtosecond timescale for materials science and biology could be achieved by single-pulse experiments (Miao et al., 1999;Neutze et al., 2000;Chapman et al., 2011). Coherent diffraction imaging (CDI) is a photon-starvation method (Gaffney & Chapman, 2007). It is a classic lens-less imaging method, proposed by Sayre in 1980and realized by Miao in 1999(Sayre et al., 1980Miao et al., 1999). The image quality of CDI is affected by the luminous flux, noise and radiation damage (Howells et al., 2009;Chapman & Nugent, 2010;Miao et al., 2015). The femtosecond pulse of XFELs enables the collection of diffraction signals before the radiation damage process, which is called 'diffraction-before-destruction' (Chapman et al., 2014). The excellent properties of the XFEL combined with CDI make high temporal and spatial resolution damage-free imaging possible. Currently, plane-wave CDI is widely used in imaging experiments at XFEL facilities (Takayama & Yonekura, 2016;Kobayashi et al., 2021). Although the photon flux of each XFEL pulse is very high, a high coherent photon flux density is also required to achieve high resolution. Usually, Kirkpatrick-Baez (KB) mirrors are used to focus the XFEL beam to increase the photon density at the sample position. The focal spot size usually ranges from a few micrometres to tens of nanometres.
For plane-wave CDI, a large spot size is generally required to illuminate the entire sample. Therefore, the spot size limits the sample size (Chapman & Nugent, 2010). In addition, the size of the XFEL spot at the sample position is an important indicator of focusing accuracy. There are well established applications for synchrotron facilities, such as photoelectric imaging (Sun et al., 2006), wire scanners (Shao et al., 2016) and synchrotron radiation interferometry (Hayano et al., 1999). However, owing to the instability of the XFEL, each XFEL pulse is unique, particularly for self-amplified spontaneous emission (Saldin et al., 1995;McNeil & Thompson, 2010). Therefore, measurement of the XFEL focal spot is required shot by shot. As the peak intensity of each XFEL pulse is very high, detectors can be damaged, and most spot-size measurement methods used in synchrotron facilities are no longer suitable. There are already a few methods to characterize the XFEL spot size, such as knife-edge scanning, damage detection on the substrate and Hartmann wavefront sensors (Koyama et al., 2013;Pikuz et al., 2015;Keitel et al., 2016;Hua et al., 2019). For example, the knife-edge scan method is widely used to measure the spot size at the focus position. To avoid radiation damage to the knife edge, the peak intensity is usually attenuated down to the radiation damage threshold, making it impossible to measure the real focus at full peak intensity. A result calculated from multiple pulses is obtained, that includes the error caused by spot instability. Hartmann wavefront sensors provide an advanced method for XFEL wavefront detection and beam characterization. However, the Hartmann wavefront sensor must be calibrated with an ideal wavefront to obtain the real spot size, and its results are affected more by systematic errors.
Here, we propose a simple but accurate method called the reconstruction method to characterize single-shot XFEL spot sizes at the focus position using CDI. The single-shot focal spot size can be quickly and accurately calculated from the reconstructed image by recording single-shot diffraction patterns and taking the phase retrieval of the diffraction pattern. Gold nanospheres and nanocubes were used to demonstrate the validity of the proposed method. Single-shot diffraction patterns from the tested samples were collected and reconstructed into images. We then used the Gaussian distribution to estimate the light spot according to the position and intensity distribution of the reconstructed samples, and acquired the XFEL spot size by two-dimensional intensity and beam fitting. A simulation was performed to verify the proposed method. The experiment was performed at the Coherent Scattering and Imaging (CSI) endstation of the Shanghai Soft X-ray Free Electron Laser Facility (SXFEL).
There are already some methods for characterizing the spot through analysis of the speckle or fluorescence. Spatiotemporal coherence, energy and spot size of XFELs have been analyzed by the scattering of single or multiple particles (Inoue et al., 2015;Yun et al., 2019;Lee et al., 2020;Nakamura et al., 2020). These methods are meaningful in XFEL pulse diagnosis. Most of them provide a statistical result, while our method can characterize a single XFEL pulse during the imaging experiment and does not require a special experimental setup.

Reconstruction method
When a coherent beam illuminates a sample, the diffraction amplitude in the far field is the Fourier transform of the light wavefront multiplied by the sample electron density distribution, and the diffraction pattern intensity is the amplitude multiplied by its conjugate, as shown in equation (1), Here, I is the intensity of the diffraction pattern, O is the light amplitude modulus distribution at the sample plane, r is the sample electron density distribution, and F is the Fourier transform operator. The intensity distribution at the focal spot of the KB mirror can be described by a two-dimensional Gaussian function, as shown in Fig. 1(a) (Self, 1983). The long and short axes of the spot should be in the horizontal (x) or vertical (y) directions because the spot is focused by horizontal and vertical KB mirrors. We used six uniform diskshaped particles with different diameters for the simulation [ Fig. 1(b)]. The sample was illuminated with a Gaussian beam, which had a spot size ! [full width at half-maximum (FWHM) of light intensity] of 1.606 mm in the horizontal direction (! x ) and 1.205 mm in the vertical direction (! y ). Its amplitude had a FWHM in the horizontal and vertical directions of FWHM Ax = 2.272 mm and FWHM Ay = 1.704 mm, respectively [ Fig. 1(a)]. The spot size is the FWHM of the light intensity, and the light intensity is proportional to the square of the amplitude. The spot size shows the product of light amplitude modulus and sample electron density at each pixel. In addition, 5% Poisson noise and 20 Â 20 pixels of missing data were added to the pattern [ Fig. 1(d)]. 2800 iterations of the hybrid input-output (HIO) and 200 iterations of the error reduction (ER) algorithm were used for reconstruction, and the results are shown in Fig. 1 The light amplitude at the center pixels of the particle can be approximated to have a uniform variation. The intensity at each pixel in the particle reconstruction was proportional to the light amplitude at that pixel multiplied by the number of electrons in the pixel. All particles were entirely composed of gold, and thus had similar electron densities. The number of electrons in each pixel was proportional to its volume or thickness. The beam intensity at each pixel can be described by the equation Since the intensity at the edge pixels in the reconstruction might be inaccurate, we selected 3 Â 3 pixels near the center of each particle to calculate the light amplitude at the center. We normalized the thicknesses of the disk-shaped particles and calculated the light amplitude at the center and the position of each particle (Table 1). The amplitude modulus of the Gaussian beam at the focal plane with the major and minor axes in the x (horizontal) or y (vertical) directions can be described by the following equation, where A is the peak amplitude, (xs, ys) is the position of the spot center, and x and y are the standard deviations which reflect the spot size. These five quantities (A, xs, ys, x , y ) were fitted. Therefore, at least five particles were required to determine the light distribution. From the reconstruction results, we can obtain the approximate area of the center of the spot and the FWHM A range. These estimates were used as the initial value and range of fit. The relative light amplitude (RA) is the average light intensity of 3 Â 3 pixels near the center. RA is proportional to actual light amplitude.  Table 1 Center position and relative light amplitude (RA) of each particle.
The particle number is labeled in Fig. 1(b). RA is the average light amplitude of 3 Â 3 pixels near the center, and is proportional to the actual light amplitude.
The subscript n means different experiment times. We find the approximate ranges of (A n , xs n , ys n , xn , yn ) from the reconstruction and fit them using least squares. Then, the spot dimensions ! x and ! y can be obtained. The comparison of the fitted spot with the reconstruction of the particles is shown in Fig. 1( f ). The agreement of the fitting result with the set value (shown in Table 2) indicates that the reconstruction method is accurate for determining the spot size.

Sample requirement
The reconstruction method has requirements for samples. If the particles in the sample are too far apart, they cannot be reconstructed. Here, we simulate using parameters close to the actual experiment: circular Gaussian beam, FWHM of beam amplitude FWHM A = 3 mm, spot size ! = 2.12 mm [ Fig. 2(a)]. The sample consists of two identical gold nanoparticles with 200 nm diameter; one is at the center of the spot and the other is at a distance d [ Fig. 2(b)]. As d increases, interference fringes in the intensity pattern become less visible [Figs. 2(c) and 2(d)]. Fig. 2(d) shows that the interference fringes are almost invisible when d is greater than 5 mm, and the sample cannot be reconstructed correctly. The spot size in the experiment is about 2 mm, so the total size of the sample cannot exceed 5 mm.
In addition to the limitation on the sample size, there is also a limitation on the number of gold nanoparticles in the sample. More particles will increase the saturation area and the difficulty of finding support. In the future, samples with limited size and particle number will make experiments more reliable.

Reconstruction method
The CSI endstation is one of the five endstations at SXFEL. It can carry out forward X-ray scattering experiments such as CDI, Fourier transform holography and small-angle X-ray scattering . Combined with a pump laser, it is possible to obtain dynamic structures of materials with femtosecond temporal resolution. Our experiment was performed at the CSI endstation of SXFEL. The SXFEL is a soft X-ray free-electron laser, with photon energies ranging from 100 eV to 620 eV. At the oxygen absorption edge, the X-ray photon energy was set to 520 eV. Two types of nanoparticles were imaged, including 200 nm gold nanospheres and 170 nm gold nanocubes. Scanning electron microscope (SEM) and transmission electron microscope   densities of the nanospheres varied because of incomplete crystallization. Figs. 3(c) and 3(d) show SEM and TEM images of the nanocubes, whose size and shape distributions were larger than those of the nanospheres. Similar to the nanospheres, the TEM image shows that the nanocubes also had different densities. The nanoparticles were deposited on Si 3 N 4 membranes with a thickness of 50 nm. The Si 3 N 4 membranes were mounted on two-dimensional scanning stages. By synchronizing the scanning stages and pulse picker with trigger signals, the single-shot diffraction pattern can be recorded by an X-ray detector (model PI-MTE3: 4096B-2), which has 15 mm Â 15 mm pixel size and 4096 Â 4096 pixels. To protect the detector from direct beams, beamstops of various diameters can be moved into the beam path. For our experiment, a 2 mm-diameter beamstop was used, and the detector was mounted 250 mm downstream of the sample. Single-shot diffraction patterns were recorded using an X-ray detector by scanning the Si 3 N 4 membranes deposited with nanoparticles using X-ray pulses. The diffraction patterns of the gold nanospheres are shown in Figs. 4(a)-4(c). The black dashed circles depict the characteristic diffraction rings. The clear interference to the side of the diffraction spots indicates that multiple nanospheres were imaged within a single pulse. For each XFEL pulse, there were approximately 10 12 photons, corresponding to approximately 100 mJ of energy . Owing to the ultrahigh flux intensity, the diffraction signals extend to the corners of the X-ray detector. The maximum spatial frequency was approximately 80 mm À1 , corresponding to a half-period resolution of 6.25 nm. Fig. 4(d) shows diffraction patterns from the gold nanocubes.
Compared with the diffraction patterns of the gold nanospheres, diffraction fringes were observed instead of diffraction rings, as indicated by the black arrows.
The images of the samples were reconstructed using a phase retrieval algorithm that included 2800 HIO iterations followed by 200 ER iterations. For each diffraction pattern, 1000 independent reconstructions were conducted. Among these, 100 independent reconstructions with the smallest reconstruction errors were averaged to obtain the final image. The reconstructed images are shown in Fig. 5. Because reconstruction is the product of gold nanoparticle densities and beam intensity distribution, the reconstructed intensities were unequal for each nanoparticle.
As shown earlier, the beam spot size can be calculated from the reconstructed images. The reconstructed images were expanded to 1000 Â 1000 pixels by padding with zeros. The position and average center intensity of each nanoparticle were calculated, as shown in Table 3. Owing to incomplete crystallization, as shown in Fig. 3, the densities of a few nanoparticles were found to be abnormal. These low-density particles were not used in the fitting process. The particle sizes are listed in Table 3. By omitting nanoparticles with abnormal density, the spot-fitting method introduced in the simulation section was applied to the reconstructed images. The distri-   Panels (a)-(d) show four patterns from different particles used for reconstruction, where (d) represents the gold cube and the rest represent the gold spheres. The black dashed circles in (a)-(d) represent the size of the zeroth-order diffraction spots and the black arrows in (d) represent the diffraction direction of the main particle. The blank parts at the top of the patterns are missing data. A beamstop with 2 mm diameter was applied in the center of the detector. The signals blocked by the beamstop and its rod cause missing data. The pattern had 3605 Â 3605 pixels and the detector pixel size was 15 mm. The background has been subtracted from each pattern. The background is a pattern without illuminated particles. A 5 Â 5 binning with 721 Â 721 pixels was applied to the patterns used for reconstruction. bution of each nanoparticle in the beam profile is shown in Fig. 6. The fitted single-shot spot sizes are presented in Table 4.
The spot size variation was calculated to be ! x = 2.10 AE 0.24 mm and ! y = 2.00 AE 0.20 mm. The advantage of the reconstruction method was the online single-shot characterization of focal spot size. In addition, the damage method, described below, was used to verify the fitting results of the reconstruction method.

Damage method
The silicon wafer coated with a 50 nm-thick layer of Si 3 N 4 was irradiated with a high-fluence focused XFEL pulse without attenuation. Fig. 7(a) shows a typical damaged area on the silicon wafer. The circular crater in the center is an ablation area, while the surface cracks may be caused by the ejection of evaporated silicon. We counted 14 ablation areas, and Fig. 7(c) shows their x-and y-axis diameters. The diameters of the ablation areas along the x and y axes are D x = 8.77 AE  Table 3 Center position and relative light amplitude of each particle in each reconstruction ]. Particles P6 in (b) and P6 in (c) (highlighted in bold) are abnormal density particles. These two particles were omitted from the inputs for fitting.

Figure 5
Normalized reconstructions of the patterns in Figs. 3(a)-3(d). The pixel size is 11.1 nm. The white labels mark the particles in each reconstructed image.

Table 4
Reconstruction fitting results.
The data are the averages of the results with the smallest errors, plus or minus one standard deviation. (xs, ys) is the position of the spot center. The average value of the five results for FWHM A and ! along the x and y axes is also shown.

Figure 6
Results of spot fitting. The blue circles mark the reconstructed particles and the background outside the blue circles shows the fitted spot amplitude. The black labels mark the abnormal density particles, which were not used for spot fitting.
0.40 mm and D y = 8.79 AE 0.31 mm. We then used a 3D confocal laser scanning microscope (3D-CLSM) to detect the damaged area, shown in Fig. 7(b). The depth of the ablation area was approximately 7 mm. The edge of the ablation area was slightly below the surface, because of which the calculated diameter was smaller than the true value. The calculated spot size was verified by evaluating the ablation area. The size of the ablation area is related to the energy density of the light and ablation threshold of the material. The threshold fluence of silicon is given by where ", A 0 , , N A and D are the absorption coefficient, average atomic weight, average density, Avogadro's constant and melting dose, respectively (Koyama et al., 2013). The threshold fluence of silicon for a wavelength of 2.4 nm is F Si ( = 2.4 nm) = (6.61 AE 0.36) Â 10 À3 mJ mm À2 . A maximum pulse energy greater than 200 mJ was achieved at the source point, and the pulse energy at our estimation is about 100 mJ . The beam condition of SXFEL is not stable enough. Thus we set the energy threshold through the gas intensity monitor detector reading. The pulse arriving at the sample point is the pulse after a high-energy pulse, which usually has high energy ($ 100 mJ) (Tong et al., 2022). However, the 50 nm-thick Si 3 N 4 layer will attenuate it by 20%.
The energy absorbed by Si was approximately 80 mJ. The energy density distribution of the spot, È(x, y), is approximately given by Here, E all = 80 mJ, x = ! x / 2[2 ln(2)] 1/2 , y = ! y /2[2 ln(2)] 1/2 . So the coefficient is given by When the beam energy density reaches the threshold fluence, È(x, y) = F Si ( = 2.4 nm) and x 2 D x =2 ð Þ 2 þ y 2 D y =2 À Á 2 ¼ 1; and ! along the x and y axes are ! x = 2.71 AE 0.14 mm, ! y = 2.72 AE 0.11 mm, respectively. These values are in good agreement  with the measured values shown in Table 4. The spot size calculated from the damage is highly dependent on the pulse energy. Due to the pulse energy fluctuation of SASE mode, the pulse energy of each shot cannot be absolutely measured during the experiments. This method uses 100 mJ for estimation, which is not accurate for the calculation of spot size. However, the ratio of the spot size in the x and y directions can be obtained from this method, which shows that the spot is close to circular.

Conclusion
The reconstruction method based on coherent diffraction imaging requires only a single pulse, and it can accurately characterize the spot, which provides an in situ real-time analysis approach for future experiments. This is also helpful for diagnosing and optimizing light sources online. Using the experimental data from the CSI endstation, the reconstruction method shows that the spot intensity at the focal point had a 2.1 mm horizontal FWHM and 2.0 mm vertical FWHM. The result obtained by the reconstruction method is consistent with that of the damage method and knife-edge scanning method . Therefore, the reconstruction method is feasible for characterization of the XFEL spot. This result is close to the minimum size of the SXFEL focus in theory, indicating that the optimization of the optical path is excellent.